package com.spooky.sync.persistence.entity;

import java.util.LinkedList;
import java.util.List;

public class ExpandableNote implements Comparable<Object> {
	private String mName = null;
	private Long mId = null;
	private String mText = null;
	private List<ExpandableNote> mNote = null;

	public ExpandableNote(Category category) {
		mName = category.getCategory();
		mId = category.getId();
		mNote = new LinkedList<ExpandableNote>();
	}

	public ExpandableNote() {
	}

	public String getName() {
		return mName;
	}

	public void setName(String name) {
		mName = name;
	}

	public Long getId() {
		return mId;
	}

	public void setId(Long id) {
		mId = id;
	}

	public List<ExpandableNote> getNote() {
		if (mNote == null) {
			mNote = new LinkedList<ExpandableNote>();
		}
		return mNote;
	}

	public void setNote(List<ExpandableNote> note) {
		mNote = note;
	}

	public void setText(String text) {
		mText = text;
	}

	public String getText() {
		return mText;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (obj instanceof ExpandableNote) {
			return ((ExpandableNote) obj).mId.equals(mId);
		}
		if (obj instanceof Long) {
			return ((Long) obj).equals(mId);
		}
		if (obj instanceof Category) {
			return ((Category) obj).mId.equals(mId);
		}
		return false;
	}

	@Override
	public int compareTo(Object obj) {
		if (obj == null) {
			return -1;
		}
		if (obj instanceof ExpandableNote) {
			return mId.compareTo(((ExpandableNote) obj).mId);
		}
		if (obj instanceof Long) {
			return mId.compareTo(((Long) obj));
		}
		if (obj instanceof Category) {
			return mId.compareTo(((Category) obj).mId);
		}
		return -1;
	}

	@Override
	public String toString() {
		return mName;
	}
}
